<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
          function user(name,age){
           this.name=name;
           this.age=age;
       }
       user.prototype.show=function(){
           console.log(this.name,this.age);
       };


       //对象封装继承

        function admin(name,age){
            const z_obj=Object.create(user.prototype);
            user.call(z_obj,name,age);
            //还可以再加方法
            z_obj.role=function(){
                 console.log("role...");
            };
            return z_obj;
        }

        let tw=new admin("唐玮",20);
        tw.show();
        tw.role();
    </script>
</body>
</html>